package cc.rengu.igas.momp.common.dao.impl;

import cc.rengu.igas.momp.common.dao.StatisticsStatementInfoMapper;
import cc.rengu.igas.momp.common.entity.*;
import cc.rengu.oltp.service.common.constant.AppConfigConstant;
import cc.rengu.oltp.service.common.constant.AppParamConstant;
import cc.rengu.oltp.utility.util.DateUtil;
import cc.rengu.oltp.utility.util.DbsUtil;
import cc.rengu.oltp.utility.util.XmlConfigUtil;
import cc.rengu.oltp.utility.util.XmlTreeUtil;
import cc.rengu.utility.cache.UnifiedCache;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 营销活动报表统计数据库操作接口实现
 *
 * @author liujinan
 * @version 1.0.0
 * @date 2020/4/1
 */
public class StatisticsStatementInfoMapperImpl implements StatisticsStatementInfoMapper {

    private RgLogger rglog = RgLog.getLogger(this.getClass().getName());
    private String dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(AppParamConstant.DATABASE_CONF_NODE, AppConfigConstant.MOMP_POOL_NAME);

    /**
     * 查询机构信息
     *
     * @param instId       法人机构号
     * @param orgCode      查询机构号
     * @param superOrgCode 上级机构号
     * @return java.util.List<Organization> 内管平台-机构管理表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/14
     */
    @Override
    public List<Organization> selectOrganization(String instId, String orgCode, String superOrgCode) throws Exception {

        String dbPoolNameOltp = XmlConfigUtil.getXmlConfigCacheKeyValue(AppParamConstant.DATABASE_CONF_NODE, AppConfigConstant.MCMP_POOL_NAME);

        String queryClause = instId + orgCode + superOrgCode;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolNameOltp = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MCMP_POOL_NAME);
        }
        DbsUtil dbsUtil = new DbsUtil(dbPoolNameOltp);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompselectOrganization");

        Organization organization = new Organization();
        organization.setInstId(instId);
        organization.setOrgCode(orgCode);
        organization.setSuperOrgCode(superOrgCode);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, organization, Organization.class);
        if (null == objectList || objectList.isEmpty()) {
            rglog.error("根据查询条件<{}>获取机构信息失败!", queryClause);
            return null;
        }
        return objectList.stream().map(item -> (Organization) (item)).collect(Collectors.toList());
    }

    /**
     * 查询减免类营销活动基本信息接口实现
     *
     * @param instId   法人机构号
     * @param mcNo     营销活动编号
     * @param mcName   营销活动名称
     * @param mcType   营销活动类型
     * @param mcStatus 营销活动状态
     * @param mcOrgId  查询机构号
     * @return java.util.List<StatisticsStatementQueryRespInfo> 营销活动统计信息报表中营销活动信息查询结果实体类
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/1
     */
    @Override
    public List<StatisticsStatementQueryRespInfo> selectMcMoneyOffListInfo(String instId, String mcNo, String mcName, String mcType, String mcStatus, String mcOrgId) throws Exception {

        String queryClause = instId + mcNo + mcName + mcType + mcStatus + mcOrgId;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectMcMoneyOffListInfo");

        // 按接口赋查询条件
        StatisticsStatementQueryInfo statisticsStatementQueryInfo = new StatisticsStatementQueryInfo();
        statisticsStatementQueryInfo.setInstId(instId);
        statisticsStatementQueryInfo.setMcNo(mcNo);
        statisticsStatementQueryInfo.setMcName(mcName);
        statisticsStatementQueryInfo.setMcType(mcType);
        statisticsStatementQueryInfo.setMcStatus(mcStatus);
        statisticsStatementQueryInfo.setMcOrgId(mcOrgId);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statisticsStatementQueryInfo, StatisticsStatementQueryRespInfo.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取减免类营销活动列表信息失败!", queryClause);
            return null;
        }
        return objectList.stream().map(item -> (StatisticsStatementQueryRespInfo) (item)).collect(Collectors.toList());
    }

    /**
     * 查询卡券类营销活动基本信息接口实现
     *
     * @param instId   法人机构号
     * @param mcNo     营销活动编号
     * @param mcName   营销活动名称
     * @param mcType   营销活动类型
     * @param mcStatus 营销活动状态
     * @param mcOrgId  查询机构号
     * @return java.util.List<StatisticsStatementQueryRespInfo> 营销活动统计信息报表中营销活动信息查询结果实体类
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/1
     */
    @Override
    public List<StatisticsStatementQueryRespInfo> selectMcCouponListInfo(String instId, String mcNo, String mcName, String mcType, String mcStatus, String mcOrgId) throws Exception {

        String queryClause = instId + mcNo + mcName + mcType + mcStatus + mcOrgId;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectMcCouponListInfo");

        // 按接口赋查询条件
        StatisticsStatementQueryInfo statisticsStatementQueryInfo = new StatisticsStatementQueryInfo();
        statisticsStatementQueryInfo.setInstId(instId);
        statisticsStatementQueryInfo.setMcNo(mcNo);
        statisticsStatementQueryInfo.setMcName(mcName);
        statisticsStatementQueryInfo.setMcType(mcType);
        statisticsStatementQueryInfo.setMcStatus(mcStatus);
        statisticsStatementQueryInfo.setMcOrgId(mcOrgId);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statisticsStatementQueryInfo, StatisticsStatementQueryRespInfo.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取卡券类营销活动列表信息失败!", queryClause);
            return null;
        }
        return objectList.stream().map(item -> (StatisticsStatementQueryRespInfo) (item)).collect(Collectors.toList());
    }

    /**
     * 查询对客营销活动统计信息
     *
     * @param instId 法人机构号
     * @param mcNo   营销活动编号
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStat2C> 对客户营销活动统计表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/1
     */
    @Override
    public List<TMStat2C> selectStatToClientListInfo(String instId, String mcNo) throws Exception {

        String queryClause = instId + mcNo;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientListInfo");

        // 按接口赋查询条件
        TMStat2C statToClient = new TMStat2C();
        statToClient.setInstId(instId);
        statToClient.setMcNo(mcNo);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statToClient, TMStat2C.class);

        if (null == objectList || objectList.size() == 0) {
            rglog.error("根据查询条件<{}>获取对客营销活动统计信息失败!", queryClause);
            return null;
        }

        return objectList.stream().map(item -> (TMStat2C) (item)).collect(Collectors.toList());
    }

    /**
     * 查询对客营销活动单日统计信息
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param transDate 交易日期
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStat2CDay> 对客户营销活动单日统计表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/1
     */
    @Override
    public List<TMStat2CDay> selectStatToClientDayListInfo(String instId, String mcNo, String transDate) throws Exception {

        String queryClause = instId + mcNo + transDate;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientDayListInfo");

        // 按接口赋查询条件
        TMStat2CDay statToClientDay = new TMStat2CDay();
        statToClientDay.setInstId(instId);
        statToClientDay.setMcNo(mcNo);
        statToClientDay.setTxnDate(transDate);
        //设置当前日期前15天是哪天
        statToClientDay.setRemark1(DateUtil.getBaseDateOffsetDay(transDate, -15));

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statToClientDay, TMStat2CDay.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取对客营销活动单日统计信息失败!", queryClause);
            return null;
        }

        return objectList.stream().map(item -> (TMStat2CDay) (item)).collect(Collectors.toList());
    }

    /**
     * 商户对客统计报表 查询减免类营销活动基本信息接口实现
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param mcName    营销活动名称
     * @param mcType    营销活动类型
     * @param mcStatus  营销活动状态
     * @param mchntArea 商圈
     * @return java.util.List<cc.rengu.igas.momp.common.entity.StatisticsStatementQueryRespInfo> 营销活动统计信息报表中营销活动信息查询结果实体类
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/12
     */
    @Override
    public List<StatisticsStatementQueryRespInfo> selectStatToClientMcMoneyOffListInfo(String instId, String mcNo, String mcName, String mcType, String mcStatus, String mchntNo, String mchntArea) throws Exception {

        String queryClause = instId + mcNo + mcName + mcType + mcStatus + mchntArea;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);

        String sqlStr;
        if (null == mchntArea || "".equals(mchntArea)) {
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientMcMoneyOffListInfo");
        } else {
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientMcMoneyOffListInfoWithMchntArea");
        }

        // 按接口赋查询条件
        StatisticsStatementQueryInfo statisticsStatementQueryInfo = new StatisticsStatementQueryInfo();
        statisticsStatementQueryInfo.setInstId(instId);
        statisticsStatementQueryInfo.setMcNo(mcNo);
        statisticsStatementQueryInfo.setMcName(mcName);
        statisticsStatementQueryInfo.setMcType(mcType);
        statisticsStatementQueryInfo.setMcStatus(mcStatus);
        statisticsStatementQueryInfo.setMchntNo(mchntNo);
        statisticsStatementQueryInfo.setMchntArea(mchntArea);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statisticsStatementQueryInfo, StatisticsStatementQueryRespInfo.class);

        if (null == objectList || objectList.size() == 0) {
            rglog.error("根据查询条件<{}>获取营销活动列表信息失败!", queryClause);
            return null;
        }
        return objectList.stream().map(item -> (StatisticsStatementQueryRespInfo) (item)).collect(Collectors.toList());
    }

    /**
     * 商户对客统计报表 查询卡券类营销活动基本信息接口实现
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param mcName    营销活动名称
     * @param mcType    营销活动类型
     * @param mcStatus  营销活动状态
     * @param mchntArea 商圈
     * @return java.util.List<cc.rengu.igas.momp.common.entity.StatisticsStatementQueryRespInfo> 营销活动统计信息报表中营销活动信息查询结果实体类
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/12
     */
    @Override
    public List<StatisticsStatementQueryRespInfo> selectStatToClientMcCouponListInfo(String instId, String mcNo, String mcName,
                                                                                     String mcType, String mcStatus, String mchntNo, String mchntArea) throws Exception {

        String queryClause = instId + mcNo + mcName + mcType + mcStatus + mchntArea;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);

        String sqlStr;
        if (null == mchntArea || "".equals(mchntArea)) {
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientMcCouponListInfo");
        } else {
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientMcCouponListInfoWithMchntArea");
        }

        // 按接口赋查询条件
        StatisticsStatementQueryInfo statisticsStatementQueryInfo = new StatisticsStatementQueryInfo();
        statisticsStatementQueryInfo.setInstId(instId);
        statisticsStatementQueryInfo.setMcNo(mcNo);
        statisticsStatementQueryInfo.setMcName(mcName);
        statisticsStatementQueryInfo.setMcType(mcType);
        statisticsStatementQueryInfo.setMcStatus(mcStatus);
        statisticsStatementQueryInfo.setMchntNo(mchntNo);
        statisticsStatementQueryInfo.setMchntArea(mchntArea);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statisticsStatementQueryInfo, StatisticsStatementQueryRespInfo.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取营销活动列表信息失败!", queryClause);
            return null;
        }
        return objectList.stream().map(item -> (StatisticsStatementQueryRespInfo) (item)).collect(Collectors.toList());
    }

    /**
     * 查询商户对客营销活动统计信息
     *
     * @param instId  法人机构号
     * @param mcNo    营销活动编号
     * @param mchntNo 商户编号
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStat2CMchnt>
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/1
     */
    @Override
    public List<TMStat2CMchnt> selectStatToClientMchntListInfo(String instId, String mcNo, String mchntNo) throws Exception {

        String queryClause = instId + mcNo;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientMchntListInfo");

        // 按接口赋查询条件
        TMStat2CMchnt statToClientMchnt = new TMStat2CMchnt();
        statToClientMchnt.setInstId(instId);
        statToClientMchnt.setMcNo(mcNo);
        statToClientMchnt.setMchntNo(mchntNo);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statToClientMchnt, TMStat2CMchnt.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取商户对客营销活动统计信息失败!", queryClause);
            return null;
        }

        return objectList.stream().map(item -> (TMStat2CMchnt) (item)).collect(Collectors.toList());
    }

    /**
     * 查询商户对客营销活动单日统计信息
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param transDate 交易日期
     * @param mchntNo   商户编号
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStat2CMchntDay> 对客户营销活动商户单日统计表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/1
     */
    @Override
    public List<TMStat2CMchntDay> selectStatToClientMchntDayListInfo(String instId, String mcNo, String transDate, String mchntNo) throws Exception {

        String queryClause = instId + mcNo + transDate;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatToClientMchntDayListInfo");

        // 按接口赋查询条件
        TMStat2CMchntDay statToClientMchntDay = new TMStat2CMchntDay();
        statToClientMchntDay.setInstId(instId);
        statToClientMchntDay.setMcNo(mcNo);
        statToClientMchntDay.setMchntNo(mchntNo);
        statToClientMchntDay.setTxnDate(transDate);
        //设置当前日期前15天是哪天
        statToClientMchntDay.setRemark1(DateUtil.getBaseDateOffsetDay(transDate, -15));

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statToClientMchntDay, TMStat2CMchntDay.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取商户对客营销活动单日统计信息失败!", queryClause);
            return null;
        }

        return objectList.stream().map(item -> (TMStat2CMchntDay) (item)).collect(Collectors.toList());
    }

    /**
     * 商户手续费优惠信息统计活动基本信息查询接口实现
     *
     * @param instId    法人机构号
     * @param mchntNo   商户编号
     * @param mchntArea 商圈编号
     * @return java.util.List<cc.rengu.igas.momp.common.entity.StatisticsStatementQueryRespInfo> 营销活动统计信息报表中营销活动信息查询结果实体类
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/3
     */
    @Override
    public List<StatisticsStatementQueryRespInfo> selectStatFeeMchntMcListInfo(String instId, String mchntNo, String mchntArea, String txnDate) throws Exception {

        String queryClause = instId + mchntNo + mchntArea;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);

        String sqlStr;
        if (null == mchntArea || "".equals(mchntArea)) {
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatFeeMchntMcListInfo");
        } else {
            sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatFeeMchntMcListInfoWithMchntArea");
        }

        // 按接口赋查询条件
        StatisticsStatementQueryInfo statisticsStatementQueryInfo = new StatisticsStatementQueryInfo();
        statisticsStatementQueryInfo.setInstId(instId);
        statisticsStatementQueryInfo.setMchntNo(mchntNo);
        statisticsStatementQueryInfo.setMchntArea(mchntArea);
        statisticsStatementQueryInfo.setMcStartDate(txnDate);
        statisticsStatementQueryInfo.setMcEndDate(txnDate);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statisticsStatementQueryInfo, StatisticsStatementQueryRespInfo.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取营销活动列表信息失败!", queryClause);
            return null;
        }
        return objectList.stream().map(item -> (StatisticsStatementQueryRespInfo) (item)).collect(Collectors.toList());
    }

    /**
     * 手续费减免活动商户统计信息
     *
     * @param instId  法人机构号
     * @param mcNo    营销活动编号
     * @param mchntNo 商户编号
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStatMfdMchnt> 手续费减免活动商户统计表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/3
     */
    @Override
    public List<TMStatMfdMchnt> selectStatFeeMchntListInfo(String instId, String mcNo, String mchntNo) throws Exception {

        String queryClause = instId + mcNo + mchntNo;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatFeeMchntListInfo");

        // 按接口赋查询条件
        TMStatMfdMchnt statFeeMchnt = new TMStatMfdMchnt();
        statFeeMchnt.setInstId(instId);
        statFeeMchnt.setMcNo(mcNo);
        statFeeMchnt.setMchntNo(mchntNo);

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statFeeMchnt, TMStatMfdMchnt.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取手续费减免活动商户统计信息失败!", queryClause);
            return null;
        }

        return objectList.stream().map(item -> (TMStatMfdMchnt) (item)).collect(Collectors.toList());
    }

    /**
     * 手续费减免活动商户单日统计信息
     *
     * @param instId    法人机构号
     * @param mcNo      营销活动编号
     * @param transDate 交易日期
     * @param mchntNo   商户编号
     * @return java.util.List<cc.rengu.igas.momp.common.entity.TMStatMfdMchntDay> 手续费减免活动商户单日统计表
     * @throws Exception 异常信息
     * @author liujinan
     * @date 2020/4/3
     */
    @Override
    public List<TMStatMfdMchntDay> selectStatFeeMchntDayListInfo(String instId, String mcNo, String transDate, String mchntNo) throws Exception {

        String queryClause = instId + mcNo + transDate + mchntNo;

        XmlTreeUtil xmlTreeUtil = new XmlTreeUtil();
        String corporation = xmlTreeUtil.getXmlTreeStringValue(AppParamConstant.CORPORATION);
        if (null != corporation && !corporation.isEmpty()) {
            String dbPoolCashNode = corporation.trim() + AppParamConstant.DATABASE_CONF_NODE;
            dbPoolName = XmlConfigUtil.getXmlConfigCacheKeyValue(dbPoolCashNode, AppConfigConstant.MOMP_POOL_NAME);
        }
        rglog.error("DBPoolName=[{}]", dbPoolName);

        DbsUtil dbsUtil = new DbsUtil(dbPoolName);
        String sqlStr = (String) UnifiedCache.get(AppParamConstant.SQL_MAPPER_CACHE, "mompSelectStatFeeMchntDayListInfo");

        // 按接口赋查询条件
        TMStatMfdMchntDay statFeeMchntDay = new TMStatMfdMchntDay();
        statFeeMchntDay.setInstId(instId);
        statFeeMchntDay.setMcNo(mcNo);
        statFeeMchntDay.setMchntNo(mchntNo);
        statFeeMchntDay.setTxnDate(transDate);
        //设置当前日期前15天是哪天
        statFeeMchntDay.setRemark1(DateUtil.getBaseDateOffsetDay(transDate, -15));

        List<Object> objectList = dbsUtil.dbsFetchLimitListData(sqlStr, statFeeMchntDay, TMStatMfdMchntDay.class);

        if (null == objectList) {
            rglog.error("根据查询条件<{}>获取手续费减免活动商户单日统计信息失败!", queryClause);
            return null;
        }

        return objectList.stream().map(item -> (TMStatMfdMchntDay) (item)).collect(Collectors.toList());
    }

}
